<template>
  <div>
    <publicPageVue :json-obj="pageSetting" name="MenuButton" :tables="tables" />
  </div>
</template>

<script>
  import { Mixin } from '@/common/minxin/Mixin'
  import { GFCD } from '@/utils/utils'
  import publicPageVue from '../../components/publicPage.vue'
  import { getList } from '../../api/home.js'
  import MenuButton from '../../components/json/MenuButton'
  export default {
    name: 'MenuButton',
    components: { publicPageVue },
    mixins: [Mixin],
    data() {
      return {
        tables: {
          tableList: [],
          count: 0,
          pageSize: 50,
          limit: 1,
          name: 'MenuButton',
          operation: false,
          isNew: true,
          width: '150',
        },
        pageSetting: {},
      }
    },
    created() {
      this.init()
    },
    methods: {
      async init() {
        this.configSetting = GFCD('dams')
        let res = await this.getModularIdData()
        let res1 = await this.getLanguage()
        let list = []
        let list1 = []
        res.forEach((item) => {
          list.push({ CODE: item.ID, LABEL: item.MENU_NAME })
        })
        res1.forEach((item) => {
          list1.push({ CODE: item.CODE_ID, LABEL: item.NAME })
        })
        // this.nowJsonData().then((data) => {
        this.pageSetting = MenuButton
        let listField = this.pageSetting.MenuButton.dialog.form.field
        listField.forEach((item) => {
          if (item.name == 'MENU_CODE') {
            item.options = list
          }
          // if (item.name == 'BUTTON_NAME') {
          //   item.options = list1
          // }
        })
        // })
      },
      //获取按钮绑定菜单下拉数据
      async getModularIdData() {
        let method = 'dams.mainmenu.query'
        let res = await getList(`${this.configSetting.domain}${this.configSetting.baseUrl}`, {
          method: method,
          data: JSON.stringify({ SUB_SYSTEM: 'DAMS', '#LIMIT#': 1, '#PAGE_SIZE#': 9999, MENU_LV: 2 }),
        })
        return res.data.second.data
      },
      async getLanguage() {
        let res = await getList(`${this.configSetting.domain}${this.configSetting.baseUrl}`, {
          data: JSON.stringify({
            '#LIMIT#': 1,
            '#PAGE_SIZE#': 99999,
            SUB_SYSTEM: 'DAMS',
          }),
          method: 'dams.language.pack.select.query',
        })
        return res.data['dams.language.pack.select.query'].data
      },
    },
  }
</script>

<style lang="scss" scoped></style>
